package com.chenwenxuan.sync.console.model;


public class TaskRuntimeInfo {
	
	private int workCount;
	private TaskDebugInfo [] debugLogs;
	private boolean enableDebugLog;
	private Throwable runtimeExcepton;
	private Task refTask;
	private String msg;
	private ReturnStatus status;
	
	public enum ReturnStatus {
		SUCCESS(0, "success"), FAILED(1, "failed"), CONTINUE(2, "continue"), UNKNOWN(-1, "unknow");
		
		private int code;
		private String name;
		
		private ReturnStatus(int code, String name) {
			this.code = code;
			this.name = name;
		}
		
		public int getCode() {
			return code;
		}
		
		public String getName() {
			return name;
		}
		
		public ReturnStatus toReturnStatus(int code) {
			switch (code) {
			case 0:
				return SUCCESS;
			case 1:
				return FAILED;
			case 2:
				return CONTINUE;
			default:
				break;
			}
			return UNKNOWN;
		}
	}
	
	public boolean isWorked() {
		return workCount > 0;
	}
	
	public boolean hasException() {
		return runtimeExcepton != null;
	}
	
	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getResultCode() {
		return hasException() ? 1 : 0;
	}
	
	public int getWorkCount() {
		return workCount;
	}
	public void setWorkCount(int workCount) {
		this.workCount = workCount;
	}
	public TaskDebugInfo [] getDebugLogs() {
		return debugLogs;
	}
	public void setDebugLogs(TaskDebugInfo [] debugLogs) {
		this.debugLogs = debugLogs;
	}
	public boolean isEnableDebugLog() {
		return enableDebugLog;
	}
	public void setEnableDebugLog(boolean enableDebugLog) {
		this.enableDebugLog = enableDebugLog;
	}
	public Throwable getRuntimeExcepton() {
		return runtimeExcepton;
	}
	public void setRuntimeExcepton(Throwable runtimeExcepton) {
		this.runtimeExcepton = runtimeExcepton;
	}

	public Task getRefTask() {
		return refTask;
	}

	public void setRefTask(Task refTask) {
		this.refTask = refTask;
	}

	public ReturnStatus getStatus() {
		return status;
	}

	public void setStatus(ReturnStatus status) {
		this.status = status;
	}
	
	

}
